
export const lsSet = (key, val) => {
  localStorage.setItem(key, JSON.stringify({[key]: val}))
}
export const lsGet = (key) => {
  const ls = JSON.parse(localStorage.getItem(key))
  return ls && ls[key]
}

export const trim = (str)=>{
  //删除左右两端的空格
  return str.replace(/\s/g, "");
}
export const mobileFilter = (mobile, separator = '-') =>{
  const reg = /(?!^)(?=(\d{4})+$)/g
  if(typeof mobile === 'string') {
    mobile = mobile.replace(reg, separator)
  }
  return mobile
}
export const padLeft = (num, n = 2) => {
  var len = num.toString().length;
  while(len < n) {
    num = "0" + num;
    len++;
  }
  return num
}